<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="工单号" prop="orderNum">
        <el-input
          v-model="queryParams.orderNum"
          placeholder="请输入工单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['prodplan:pworkorder:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['prodplan:pworkorder:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['prodplan:pworkorder:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleConfirm"
          v-hasPermi="['prodplan:pworkorder:confirm']"
        >计划确认</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUnConfirm"
          v-hasPermi="['prodplan:pworkorder:unconfirm']"
        >反计划确认</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleIssue"
          v-hasPermi="['prodplan:pworkorder:issue']"
        >下达</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUnIssue"
          v-hasPermi="['prodplan:pworkorder:unissue']"
        >反下达</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleStartUp"
          v-hasPermi="['prodplan:pworkorder:startup']"
        >开工</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUnStartUp"
          v-hasPermi="['prodplan:pworkorder:unstartup']"
        >反开工</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleClosed"
          v-hasPermi="['prodplan:pworkorder:closed']"
        >结案</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUnClosed"
          v-hasPermi="['prodplan:pworkorder:unclosed']"
        >反结案</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleHangUp"
          v-hasPermi="['prodplan:pworkorder:hangup']"
        >挂起</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleHangDown"
          v-hasPermi="['prodplan:pworkorder:hangdown']"
        >反挂起</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleCompletion"
          v-hasPermi="['prodplan:pworkorder:completion']"
        >完工</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['prodplan:pworkorder:export']"
        >导出</el-button>
      </el-col> -->
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table  @cell-click="handle" v-loading="loading" :data="pworkorderList" @selection-change="handleSelectionChange" :default-sort="{prop: 'date', order: 'descending'}" ref="tableDatas">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="工单号" align="center" prop="orderNum" sortable width="150"  />
      <!-- <el-table-column label="产品id" align="center" prop="productId" sortable width="150"/> -->
      <el-table-column label="结案原因" align="center" prop="closeStatus" :formatter="closeStatusFormat" sortable width="150"/>
      <el-table-column label="执行状态" align="center" prop="exeStatus" :formatter="exeStatusFormat" sortable width="150"/>
      <el-table-column label="产品编码" align="center" prop="productCode" sortable width="150"/>
      <el-table-column label="产品名称" align="center" prop="productName" sortable width="150"/>
      <el-table-column label="规格型号" align="center" prop="specModel" sortable width="150"/>
      <el-table-column label="需求数量" align="center" prop="quantity" sortable width="150"/>
      <el-table-column label="计划生产数量" align="center" prop="needQuantity" sortable width="150"/>
      <el-table-column label="单位" align="center" prop="unit" sortable width="150"/>
      <el-table-column label="车间" align="center" prop="workshop" sortable width="150"/>
      <el-table-column label="产线" align="center" prop="prodLine" sortable width="150"/>
      <el-table-column label="班组" align="center" prop="team" :formatter="teamFormat" />
      <el-table-column label="班次" align="center" prop="frequency" :formatter="frequencyFormat" />
      <el-table-column label="排产日期" align="center" prop="planningDate" sortable width="150">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planningDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划开工日期" align="center" prop="startDate" sortable width="150">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划完工日期" align="center" prop="endDate" sortable width="150">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单据来源" align="center" prop="prodType" :formatter="prodTypeFormat" sortable width="150"/>
      <el-table-column label="工单类型" align="center" prop="orderType" :formatter="orderTypeFormat" sortable width="150"/>
      <el-table-column label="领料标识" align="center" prop="pickingMark" :formatter="pickingMarkFormat" sortable width="150"/>
      <el-table-column label="入库标识" align="center" prop="inIden" :formatter="inIdenFormat" sortable width="150"/>
            <el-table-column label="bom版本号" align="center" prop="bomVersion" sortable width="150"/>
      <el-table-column label="单据状态" align="center" prop="docStatus" :formatter="docStatusFormat" sortable width="150"/>
      <el-table-column label="创建时间" align="center" prop="createTime" sortable width="150">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="createUser" sortable width="150"/>
      <el-table-column label="修改时间" align="center" prop="updateTime" sortable width="150">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改人" align="center" prop="updateUser" sortable width="150"/>
      <el-table-column label="备注" align="center" prop="remark" sortable width="150"/>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 新增工单管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
        <!-- <el-col :span="6">
        <el-form-item label="工单号" prop="orderNum" >
          <el-input v-model="form.orderNum" placeholder="请输入工单号" />
        </el-form-item>
        </el-col> -->
        <el-col :span="6">
        <el-form-item label="工单类型" prop="orderType">
        <el-select v-model="form.orderType" placeholder="请选择工单类型" clearable size="small">
          <el-option
            v-for="dict in orderTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
        </el-form-item>
        </el-col>
        <!-- <<el-col :span="6">
        <el-form-item label="产品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入产品id" />
        </el-form-item>
        </el-col> -->
       
          <el-col :span="6">
            <el-form-item label="产品编码" prop="productCode">
          <el-select
            filterable
            :loading="loading"
            v-model="form.productCode"
            placeholder="请输入或选择产品编码"
            style="width: 100%"
            @change="setallgoods"
            remote
            :remote-method="loadgoods"            
          >
            <el-option
              v-for="dict in productOptions"
              :key="dict.productId"
              :label="`${dict.goodsCode} -- ${dict.name} -- ${dict.goodsModel}`"
              :value="`${dict.goodsId}|${dict.goodsCode}|${dict.name}|${dict.goodsModel}|${dict.basicUnit}`"
            ></el-option>
          </el-select>
        </el-form-item>
            </el-col>
        </el-row>          
       <el-row>
        <el-col :span="6">
        <el-form-item label="bom版本" prop="` `">
          <el-input v-model="form.bomVersion" placeholder="请输入bom版本号"  readonly/>
        </el-form-item>
        </el-col>  
        <el-col :span="6">
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称"  readonly/>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="规格型号" prop="specModel">
          <el-input v-model="form.specModel" placeholder="请输入规格型号" readonly />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" readonly />
        </el-form-item>
        </el-col>
      </el-row>
        <el-row>
        <el-col :span="6">
        <el-form-item label="需求数量" prop="quantity" :disabled="true">
          <el-input v-model="form.quantity" placeholder="请输入需求数量" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="计划生产数量" prop="needQuantity" :disabled="true">
          <el-input v-model="form.needQuantity" placeholder="请输入计划生产数量" @blur="verifynum('sl')"/>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="计划开工日期" prop="startDate">
          <el-date-picker clearable size="small" style="width: 150px"
            v-model="form.startDate"
            type="date"
            default-value
            value-format="yyyy-MM-dd"
            placeholder="选择计划开工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="计划完工日期" prop="endDate">
          <el-date-picker clearable size="small" style="width: 150px"
            v-model="form.endDate"
            type="date"
            default-value
            value-format="yyyy-MM-dd"
            placeholder="选择计划完工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
  <el-row>
        <el-col :span="6">
  <el-form-item label="完工入库超收比例" prop="excessRate">
          <el-input v-model="form.excessRate" placeholder="请输入完工入库超收比例" @blur="verifynum('cs')"/>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="完工入库上限" prop="uplimit">
          <el-input v-model="form.uplimit" placeholder="请输入完工入库上限" @blur="verifynum('sx')"/>
        </el-form-item>
        </el-col>
        <el-col :span="6">
                <el-form-item label="完工入库欠收比例" prop="poorRate">
          <el-input v-model="form.poorRate" placeholder="请输入完工入库欠收比例" @blur="verifynum('qs')"/>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="完工入库下限" prop="lowlimit">
          <el-input v-model="form.lowlimit" placeholder="请输入完工入库下限" @blur="verifynum('xx')"/>
        </el-form-item>
 </el-col>
        </el-row>
        <el-row>
<el-col :span="6">
    <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
        <el-col :span="6">
        <el-form-item label="车间" prop="workshop">
              <el-select v-model="form.workshop" placeholder="请选择"
                 @change="getline">
                <el-option
                  v-for="item in workshopOptions"
                  :key="item.workshoptId"
                  :label="item.workshopName"
                  :value="item.workshopName"
               
                ></el-option>
              </el-select>
          </el-form-item>
           </el-col>
        <el-col :span="6">
                <el-form-item label="产线" prop="prodLine">
          <el-select
            v-model="form.prodLine"
            placeholder="请选择产线"
          >
            <el-option
              v-for="dict in LineOptions"
              :key="dict.prodlineName"
              :label="dict.prodlineName"
              :value="dict.prodlineName"
            ></el-option>
          </el-select>
        </el-form-item>
         </el-col> 
          <el-col :span="6">
          <el-form-item label="班组" prop="team">
          <el-select v-model="form.team" placeholder="请选择班组">
            <el-option
              v-for="dict in teamOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="班次" prop="frequency">
          <el-select v-model="form.frequency" placeholder="请选择班次">
            <el-option
              v-for="dict in frequencyOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        </el-row>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 修改工单管理对话框 -->
    <el-dialog :title="title" :visible.sync="editopen" width="1100px" append-to-body>
      
       <!-- <el-row>
        <el-col :span="6">
        <el-form-item label="工单号" prop="orderNum" >
          <el-input v-model="editform.orderNum" placeholder="请输入工单号" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="工单类型" prop="orderType">
        <el-select v-model="editform.orderType" placeholder="请选择工单类型" clearable size="small">
          <el-option
            v-for="dict in orderTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            
            :value="parseInt(dict.dictValue)"
          />
        </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="产品id" prop="productId">
          <el-input v-model="editform.productId" placeholder="请输入产品id" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="bom版本" prop="bomVersion">
          <el-input v-model="editform.bomVersion" placeholder="请输入bom版本号" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <el-col :span="6">
        <el-form-item label="产品编码" prop="productCode">
          <el-input v-model="editform.productCode" placeholder="请输入产品编码" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="editform.productName" placeholder="请输入产品名称" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="规格型号" prop="specModel">
          <el-input v-model="editform.specModel" placeholder="请输入规格型号" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="单位" prop="unit">
          <el-input v-model="editform.unit" placeholder="请输入单位" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <el-col :span="6">
        <el-form-item label="需求数量" prop="quantity" :disabled="true">
          <el-input v-model="editform.quantity" placeholder="请输入需求数量" />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="计划生产数量" prop="needQuantity" :disabled="true">
          <el-input v-model="editform.needQuantity" placeholder="请输入计划生产数量"   />
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="开工日期" prop="startDate">
          <el-date-picker clearable size="small" style="width: 150px"
            v-model="editform.startDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="完工日期" prop="endDate">
          <el-date-picker clearable size="small" style="width: 150px"
            v-model="editform.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择完工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <el-form-item label="车间" prop="workshop">
              <el-select v-model="editform.workshop" placeholder="请选择">
                <el-option
                  v-for="item in workshopOptions"
                  :key="item.workshoptId"
                  :label="item.workshopName"
                  :value="item.workshopId"
                  :disabled="item.status == 1"
                ></el-option>
              </el-select>
          </el-form-item> 
          <el-col :span="6">
          <el-form-item label="班组" prop="team">
          <el-select v-model="editform.team" placeholder="请选择班组">
            <el-option
              v-for="dict in teamOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="班次" prop="frequency">
          <el-select v-model="editform.frequency" placeholder="请选择班次">
            <el-option
              v-for="dict in frequencyOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        </el-row>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="editform.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form> -->
      <el-form ref="editform" :model="editform" :rules="rules" label-width="80px">
         <el-row>
           <el-col :span="12">
        <el-form-item label="工单号" prop="orderNum">
          <el-input v-model="editform.orderNum" placeholder="请输入工单号" disabled="true"/>
        </el-form-item>
           </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="产品id" prop="productId">
          <el-input v-model="editform.productId" placeholder="请输入产品id" />
        </el-form-item> -->
        <el-form-item label="订单编号" prop="docNum">
          <el-input v-model="editform.docNum" placeholder="请输入订单编号" disabled="true"/>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="bom版本号" prop="bomVersion">
          <el-input v-model="editform.bomVersion" placeholder="请输入bom版本号" disabled="true"/>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="产品编码" prop="productCode">
          <el-input v-model="editform.productCode" placeholder="请选择产品编码" disabled="true"/>
        </el-form-item> -->

        <el-form-item label="产品编码" prop="productCode">
          <el-select
            filterable
            :loading="loading"
            v-model="editform.productCode"
            placeholder="请输入或选择产品编码"
            style="width: 100%"
            @change="setallgoodss"
            remote
            :remote-method="loadgoods"   
          >
            <el-option
              v-for="dict in productOptions"
              :key="dict.productId"
              :label="`${dict.goodsCode} -- ${dict.name} -- ${dict.goodsModel}`"
              :value="`${dict.goodsId}|${dict.goodsCode}|${dict.name}|${dict.goodsModel}|${dict.basicUnit}`"
            ></el-option>
          </el-select>
        </el-form-item>







        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="editform.productName" placeholder="请输入产品名称" readonly/>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="规格型号" prop="specModel">
          <el-input v-model="editform.specModel" placeholder="请输入规格型号" readonly/>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="单位" prop="unit">
          <el-input v-model="editform.unit" placeholder="请输入单位" readonly/>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="需求数量" prop="quantity">
          <el-input v-model="editform.quantity" placeholder="请输入需求数量" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="计划生产数量" prop="needQuantity">
          <el-input v-model="editform.needQuantity" placeholder="请输入计划生产数量" @blur="verifynum('xgsl')" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="排产日期" prop="planningDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.planningDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择排产日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="开工日期" prop="startDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.startDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开工日期">
          </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="损耗率" prop="lossRate">
          <el-input v-model="editform.lossRate" placeholder="请输入损耗率" />
        </el-form-item> -->
        </el-col>
           <el-col :span="12">
        <el-form-item label="完工日期" prop="endDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择完工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="生产类型" prop="prodType">
          <el-select v-model="editform.prodType" placeholder="请选择生产类型">
            <el-option
              v-for="dict in prodTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="单据状态" prop="docStatus">
          <el-select v-model="editform.docStatus" placeholder="请选择单据状态">
            <el-option
              v-for="dict in docStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <!-- <el-form-item label="关闭状态" prop="closeStatus">
          <el-select v-model="editform.closeStatus" placeholder="请选择关闭状态(0自动关闭,1手工关闭)">
            <el-option
              v-for="dict in closeStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="审核状态" prop="auditStatus">
          <el-select v-model="editform.auditStatus" placeholder="请选择审核状态">
            <el-option
              v-for="dict in auditStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item> -->
           <el-col :span="12">
        <el-form-item label="工单类型" prop="orderType">
          <el-select v-model="editform.orderType" placeholder="请选择工单类型">
            <el-option
              v-for="dict in orderTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="执行状态" prop="exeStatus">
          <el-select v-model="editform.exeStatus" placeholder="请选择执行状态">
            <el-option
              v-for="dict in exeStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
        <!-- <el-form-item label="领料标识" prop="pickingMark">
          <el-select v-model="editform.pickingMark" placeholder="请选择领料标识">
            <el-option
              v-for="dict in pickingMarkOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="入库标识" prop="inIden">
          <el-select v-model="editform.inIden" placeholder="请选择入库标识">
            <el-option
              v-for="dict in inIdenOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="记录上一次执行状态" prop="exeLasttime">
          <el-input v-model="editform.exeLasttime" placeholder="请输入记录上一次执行状态" />
        </el-form-item> -->
           <el-col :span="12">
        <!-- <el-form-item label="车间" prop="workshop">
          <el-input v-model="editform.workshop" placeholder="请输入车间" />
        </el-form-item> -->




         <el-form-item label="车间" prop="workshop">
              <el-select v-model="editform.workshop" placeholder="请选择"
                 @change="getline">
                <el-option
                  v-for="item in workshopOptions"
                  :key="item.workshoptId"
                  :label="item.workshopName"
                  :value="item.workshopName"
               
                ></el-option>
              </el-select>
          </el-form-item>





        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="变更原因" prop="changeReason">
          <el-input v-model="editform.changeReason" placeholder="请输入变更原因" />
        </el-form-item> -->
        <el-form-item label="备注" prop="remark">
          <el-input v-model="editform.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="批号" prop="batchNum">
          <el-input v-model="editform.batchNum" placeholder="请输入批号" />
        </el-form-item> -->
        <!-- <el-form-item label="BOM编号" prop="bomCode">
          <el-input v-model="editform.bomCode" placeholder="请输入BOM编号" />
        </el-form-item>
        <el-form-item label="成本对象" prop="costObject">
          <el-input v-model="editform.costObject" placeholder="请输入成本对象" />
        </el-form-item> -->
        <el-form-item label="单据来源" prop="docSource">
          <el-input v-model="editform.docSource" placeholder="请输入单据来源" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="计划订单号" prop="planorderNum">
          <el-input v-model="editform.planorderNum" placeholder="请输入计划订单号" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="销售订单号" prop="salesorderNum">
          <el-input v-model="editform.salesorderNum" placeholder="请输入销售订单号" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="委托加工单位" prop="processCompany">
          <el-input v-model="editform.processCompany" placeholder="请输入委托加工单位" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="常用单位" prop="commonUnit">
          <el-input v-model="editform.commonUnit" placeholder="请输入常用单位" />
        </el-form-item> -->
        <el-form-item label="工艺路线" prop="processRoute">
          <el-input v-model="editform.processRoute" placeholder="请输入工艺路线" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="物料代码" prop="goodsCode">
          <el-input v-model="editform.goodsCode" placeholder="请输入物料代码" />
        </el-form-item> -->
        <!-- <el-form-item label="基本单位" prop="basicUnit">
          <el-input v-model="editform.basicUnit" placeholder="请输入基本单位" />
        </el-form-item>
        <el-form-item label="基本单位数量" prop="basicunitNum">
          <el-input v-model="editform.basicunitNum" placeholder="请输入基本单位数量" />
        </el-form-item>
        <el-form-item label="常用单位数量" prop="commonunitNum">
          <el-input v-model="editform.commonunitNum" placeholder="请输入常用单位数量" />
        </el-form-item> -->
        <!-- <el-form-item label="实作数量" prop="implQuantity">
          <el-input v-model="editform.implQuantity" placeholder="请输入实作数量" />
        </el-form-item>
        <el-form-item label="合格品入库数量" prop="qualifyinNum">
          <el-input v-model="editform.qualifyinNum" placeholder="请输入合格品入库数量" />
        </el-form-item>
        <el-form-item label="合格数量" prop="qualifyNum">
          <el-input v-model="editform.qualifyNum" placeholder="请输入合格数量" />
        </el-form-item>
        <el-form-item label="因工报废数量" prop="workdueNum">
          <el-input v-model="editform.workdueNum" placeholder="请输入因工报废数量" />
        </el-form-item>
        <el-form-item label="因料报废数量" prop="goodsdueNum">
          <el-input v-model="editform.goodsdueNum" placeholder="请输入因料报废数量" />
        </el-form-item>
        <el-form-item label="遗失数量" prop="lostNum">
          <el-input v-model="editform.lostNum" placeholder="请输入遗失数量" />
        </el-form-item>
        <el-form-item label="人工实作工时" prop="workHours">
          <el-input v-model="editform.workHours" placeholder="请输入人工实作工时" />
        </el-form-item>
        <el-form-item label="机台准备工时" prop="preparationHours">
          <el-input v-model="editform.preparationHours" placeholder="请输入机台准备工时" />
        </el-form-item>
        <el-form-item label="机台实作工时" prop="maworkHours">
          <el-input v-model="editform.maworkHours" placeholder="请输入机台实作工时" />
        </el-form-item>
        <el-form-item label="单据下达日期" prop="issuanceDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.issuanceDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择单据下达日期">
          </el-date-picker>
        </el-form-item> -->
        <el-form-item label="实际开工日期" prop="realstartDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.realstartDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择实际开工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="实际完工日期" prop="realendDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.realendDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择实际完工日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="下达人" prop="issueman">
          <el-input v-model="editform.issueman" placeholder="请输入下达人" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="结案人" prop="closeman">
          <el-input v-model="editform.closeman" placeholder="请输入结案人" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="结案日期" prop="closeDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.closeDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结案日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="上级任务单号" prop="taskorderNum">
          <el-input v-model="editform.taskorderNum" placeholder="请输入上级任务单号" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="预测单号" prop="forecastNum">
          <el-input v-model="editform.forecastNum" placeholder="请输入预测单号" />
        </el-form-item>
        <el-form-item label="源单行号" prop="singlelineNum">
          <el-input v-model="editform.singlelineNum" placeholder="请输入源单行号" />
        </el-form-item> -->
        <!-- <el-form-item label="投料单审核标志" prop="auditMark">
          <el-input v-model="editform.auditMark" placeholder="请输入投料单审核标志" />
        </el-form-item>
        <el-form-item label="严格跟单标记" prop="strictMark">
          <el-input v-model="editform.strictMark" placeholder="请输入严格跟单标记" />
        </el-form-item>
        <el-form-item label="补充库存标记" prop="replenishMark">
          <el-input v-model="editform.replenishMark" placeholder="请输入补充库存标记" />
        </el-form-item> -->
        <el-form-item label="完工入库超收比例" prop="excessRate">
          <el-input v-model="editform.excessRate" placeholder="请输入完工入库超收比例" @blur="verifynum('xgcs')"/>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="完工入库上限" prop="uplimit">
          <el-input v-model="editform.uplimit" placeholder="请输入完工入库上限" @blur="verifynum('xgsx')"/>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="完工入库欠收比例" prop="poorRate">
          <el-input v-model="editform.poorRate" placeholder="请输入完工入库欠收比例" @blur="verifynum('xgqs')"/>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="完工入库下限" prop="lowlimit">
          <el-input v-model="editform.lowlimit" placeholder="请输入完工入库下限" @blur="verifynum('xgxx')"/>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="变更次数" prop="changeNum">
          <el-input v-model="editform.changeNum" placeholder="请输入变更次数" />
        </el-form-item>
        <el-form-item label="计划模式" prop="planModel">
          <el-input v-model="editform.planModel" placeholder="请输入计划模式" />
        </el-form-item>
        <el-form-item label="打印次数" prop="printNum">
          <el-input v-model="editform.printNum" placeholder="请输入打印次数" />
        </el-form-item>
        <el-form-item label="计划跟踪号" prop="trackeNum">
          <el-input v-model="editform.trackeNum" placeholder="请输入计划跟踪号" />
        </el-form-item>
        <el-form-item label="人工准备工时" prop="prepareHours">
          <el-input v-model="editform.prepareHours" placeholder="请输入人工准备工时" />
        </el-form-item>
        <el-form-item label="流转卡关联关闭" prop="associationClose">
          <el-input v-model="editform.associationClose" placeholder="请输入流转卡关联关闭" />
        </el-form-item>
        <el-form-item label="财务结算标志" prop="financialMark">
          <el-input v-model="editform.financialMark" placeholder="请输入财务结算标志" />
        </el-form-item>
        <el-form-item label="财务结算人" prop="financialMan">
          <el-input v-model="editform.financialMan" placeholder="请输入财务结算人" />
        </el-form-item>
        <el-form-item label="财务结算日期" prop="financialDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.financialDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择财务结算日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="凭证字号" prop="voucherFont">
          <el-input v-model="editform.voucherFont" placeholder="请输入凭证字号" />
        </el-form-item> -->
        <el-form-item label="BOM类别" prop="bomClass">
          <el-input v-model="editform.bomClass" placeholder="请输入BOM类别" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="请检关联数量" prop="pcassociateNum">
          <el-input v-model="editform.pcassociateNum" placeholder="请输入请检关联数量" />
        </el-form-item>
        <el-form-item label="基本单位请检关联数量" prop="basicassociateNum">
          <el-input v-model="editform.basicassociateNum" placeholder="请输入基本单位请检关联数量" />
        </el-form-item>
        <el-form-item label="返修数量" prop="repairnum">
          <el-input v-model="editform.repairnum" placeholder="请输入返修数量" />
        </el-form-item>
        <el-form-item label="基本单位返修数量" prop="basicRepairnum">
          <el-input v-model="editform.basicRepairnum" placeholder="请输入基本单位返修数量" />
        </el-form-item>
        <el-form-item label="报废入库选单数量" prop="scrapmenuNum">
          <el-input v-model="editform.scrapmenuNum" placeholder="请输入报废入库选单数量" />
        </el-form-item>
        <el-form-item label="基本单位报入库选单数" prop="reportmenuNum">
          <el-input v-model="editform.reportmenuNum" placeholder="请输入基本单位报入库选单数" />
        </el-form-item>
        <el-form-item label="报废入库数量" prop="scrapNum">
          <el-input v-model="editform.scrapNum" placeholder="请输入报废入库数量" />
        </el-form-item>
        <el-form-item label="基本单位报废入库数量" prop="basicscrapNum">
          <el-input v-model="editform.basicscrapNum" placeholder="请输入基本单位报废入库数量" />
        </el-form-item>
        <el-form-item label="样本破坏数量" prop="damageNum">
          <el-input v-model="editform.damageNum" placeholder="请输入样本破坏数量" />
        </el-form-item>
        <el-form-item label="基本单位样本破坏数量" prop="basicdamageNum">
          <el-input v-model="editform.basicdamageNum" placeholder="请输入基本单位样本破坏数量" />
        </el-form-item>
        <el-form-item label="辅助属性名称" prop="secondaryName">
          <el-input v-model="editform.secondaryName" placeholder="请输入辅助属性名称" />
        </el-form-item>
        <el-form-item label="生产负责人" prop="prodResponsible">
          <el-input v-model="editform.prodResponsible" placeholder="请输入生产负责人" />
        </el-form-item>
        <el-form-item label="作业排程引入" prop="jobIntroduce">
          <el-input v-model="editform.jobIntroduce" placeholder="请输入作业排程引入" />
        </el-form-item>
        <el-form-item label="下达车间" prop="sendWorkshop">
          <el-input v-model="editform.sendWorkshop" placeholder="请输入下达车间" />
        </el-form-item>
        <el-form-item label="等极品入库数" prop="goodsinNum">
          <el-input v-model="editform.goodsinNum" placeholder="请输入等极品入库数" />
        </el-form-item> -->
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="editform.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="源单号" prop="sourceNum">
          <el-input v-model="editform.sourceNum" placeholder="请输入源单号" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="制单时间" prop="makeTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.makeTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择制单时间">
          </el-date-picker>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="计划交货日期" prop="planDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.planDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择计划交货日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="客户料号" prop="customergoodsCode">
          <el-input v-model="editform.customergoodsCode" placeholder="请输入客户料号" />
        </el-form-item>
        <el-form-item label="生成下级任务单标志" prop="subordinateFlag">
          <el-input v-model="editform.subordinateFlag" placeholder="请输入生成下级任务单标志" />
        </el-form-item>
        <el-form-item label="上料数" prop="upgoodsNum">
          <el-input v-model="editform.upgoodsNum" placeholder="请输入上料数" />
        </el-form-item> -->
        <!-- <el-form-item label="总报工数" prop="totalreportNum">
          <el-input v-model="editform.totalreportNum" placeholder="请输入总报工数" />
        </el-form-item> -->
        <el-form-item label="已报工数" prop="alreadyreportNum">
          <el-input v-model="editform.alreadyreportNum" placeholder="请输入已报工数" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="已入库总数" prop="totalstoresNum">
          <el-input v-model="editform.totalstoresNum" placeholder="请输入已入库总数" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="已入良品数" prop="goodNum">
          <el-input v-model="editform.goodNum" placeholder="请输入已入良品数" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="总上料数" prop="totupgoodsNum">
          <el-input v-model="editform.totupgoodsNum" placeholder="请输入总上料数" />
        </el-form-item> -->
        <el-form-item label="已入不良品数" prop="badNum">
          <el-input v-model="editform.badNum" placeholder="请输入已入不良品数" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="来源" prop="source">
          <el-input v-model="editform.source" placeholder="请输入来源" />
        </el-form-item>
        <el-form-item label="可用库存" prop="avaInventory">
          <el-input v-model="editform.avaInventory" placeholder="请输入可用库存" />
        </el-form-item> -->
        <!-- <el-form-item label="打包状态" prop="packingCondition">
          <el-select v-model="editform.packingCondition" placeholder="请选择打包状态">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="报工类型" prop="reportType">
          <el-select v-model="editform.reportType" placeholder="请选择报工类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="检验状态" prop="inspectionStatus">
          <el-select v-model="editform.inspectionStatus" placeholder="请选择检验状态">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="产线" prop="prodLine">
          <el-input v-model="editform.prodLine" placeholder="请输入产线" />
        </el-form-item> -->
                <el-form-item label="产线" prop="prodLine">
          <el-select
            v-model="editform.prodLine"
            placeholder="请选择产线"
          >
            <el-option
              v-for="dict in LineOptions"
              :key="dict.prodlineName"
              :label="dict.prodlineName"
              :value="dict.prodlineName"
            ></el-option>
          </el-select>
        </el-form-item>




        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="单据类型(0未出良品，1已出良品)" prop="fcheckType">
          <el-select v-model="editform.fcheckType" placeholder="请选择单据类型(0未出良品，1已出良品)">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item> -->
        <el-form-item label="班组" prop="team">
          <el-select v-model="editform.team" placeholder="请选择班组">
            <el-option
              v-for="dict in teamOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="班次" prop="frequency">
          <el-select v-model="editform.frequency" placeholder="请选择班次">
            <el-option
              v-for="dict in frequencyOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="开始时间" prop="starttime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.starttime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="endtime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.endtime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="首检状态(0是 1否)" prop="isType">
          <el-select v-model="editform.isType" placeholder="请选择首检状态(0是 1否)">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item> -->
        <el-form-item label="制单人" prop="singlePerson">
          <el-input v-model="editform.singlePerson" placeholder="请输入制单人" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="手工结案" prop="handClose">
          <el-input v-model="editform.handClose" placeholder="请输入手工结案" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <!-- <el-form-item label="锁单标记" prop="lockMark">
          <el-input v-model="editform.lockMark" placeholder="请输入锁单标记" />
        </el-form-item> -->
        <el-form-item label="确认人" prop="confirmer">
          <el-input v-model="editform.confirmer" placeholder="请输入确认人" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="日期" prop="date">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.date"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker> 
        </el-form-item>-->
        <el-form-item label="物料名称" prop="goodsName">
          <el-input v-model="editform.goodsName" placeholder="请输入物料名称" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="mrp计算标记" prop="mrpcalMark">
          <el-input v-model="editform.mrpcalMark" placeholder="请输入mrp计算标记" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="生产数量" prop="prodQuantity">
          <el-input v-model="editform.prodQuantity" placeholder="请输入生产数量" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="入库数量" prop="inQuantity">
          <el-input v-model="editform.inQuantity" placeholder="请输入入库数量" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="计划确认" prop="planConfirm">
          <el-input v-model="editform.planConfirm" placeholder="请输入计划确认" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="生产预测单号" prop="foreNum">
          <el-input v-model="editform.foreNum" placeholder="请输入生产预测单号" />
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <!-- <el-form-item label="计划类别" prop="planCate">
          <el-input v-model="editform.planCate" placeholder="请输入计划类别" />
        </el-form-item>
        <el-form-item label="
辅助属性代码" prop="secondaryCode">
          <el-input v-model="editform.secondaryCode" placeholder="请输入
辅助属性代码" />
        </el-form-item>
        <el-form-item label="等级品入库数" prop="gradeNum">
          <el-input v-model="editform.gradeNum" placeholder="请输入等级品入库数" />
        </el-form-item>
        <el-form-item label=" 辅助属性" prop="auxiliaryProperties">
          <el-input v-model="editform.auxiliaryProperties" placeholder="请输入 辅助属性" />
        </el-form-item> -->
        <el-form-item label="制单人" prop="producer">
          <el-input v-model="editform.producer" placeholder="请输入制单人" />
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="制单日期" prop="preparationDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.preparationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择制单日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
        <el-row>
           <el-col :span="12">
        <el-form-item label="计划关闭状态">
          <el-radio-group v-model="editform.planCloseStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        </el-col>
           <el-col :span="12">
        <el-form-item label="单据确认日期" prop="documentConfirmationDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="editform.documentConfirmationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择单据确认日期">
          </el-date-picker>
        </el-form-item>
        </el-col>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="editsubmitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 挂起提交审核 -->
    <el-dialog :title="title" :visible.sync="open1" width="500px" append-to-body >
      <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">
        <el-form-item label="变更原因" prop="changeReason">
          <el-input v-model="form1.changeReason" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form> 
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> 
    </el-dialog>

    <!-- 反挂起提交审核 -->
    <el-dialog :title="title" :visible.sync="open2" width="500px" append-to-body >
      <el-form ref="form2" :model="form2" :rules="rules" label-width="80px">
        <el-form-item label="变更原因" prop="changeReason">
          <el-input v-model="form2.changeReason" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form> 
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm2">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> 
    </el-dialog>

    <!-- 结案提交审核 -->
    <el-dialog :title="title" :visible.sync="open3" width="500px" append-to-body >
      <el-form ref="form3" :model="form3" :rules="rules" label-width="80px">
        <el-form-item label="变更原因" prop="changeReason">
          <el-input v-model="form3.changeReason" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form> 
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm3">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> 
    </el-dialog>

    <!-- 反结案提交审核 -->
    <el-dialog :title="title" :visible.sync="open4" width="500px" append-to-body >
      <el-form ref="form4" :model="form4" :rules="rules" label-width="80px">
        <el-form-item label="变更原因" prop="changeReason">
          <el-input v-model="form4.changeReason" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form> 
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm4">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> 
    </el-dialog>
  </div>
</template>

<script>
import { getlistprodbycond,listLine,getlistprod,getOrderNum,listPworkorder, getPworkorder, delPworkorder, addPworkorder, updatePworkorder, exportPworkorder, IsCompletion, confirm, unConfirm, issue, unIssue, startup, unStartup, hangup, hangdown, closed, unclosed, completion ,listWorkShop } from "@/api/prodplan/pworkorder";
import { listFeeding} from "@/api/prodplan/feeding";
import { listTransfer} from "@/api/warehouse/transfer";
import {accDiv,accMul,accAdd,accSubtr} from "@/utils/index";

export default {
  name: "Pworkorder",
  components: {
  },
  data() {
  var checkdate = (rule, value, callback) => {
      if(this.form.startDate>this.form.endDate){
      callback("计划结束日期不能早于计划开工日期，请重新选择");
      }else{
        callback();
      }
  };

    var checkminzero = (rule, value, callback) => {
      if(value<0){
      callback("数值不能小于0");
      }else{
        callback();
      }
  };
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 工单管理表格数据
      pworkorderList: [],
      //产品id代码名称
      productOptions:[],
      //产线
      LineOptions:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      open2: false,
      open3: false,
      open4: false,
      editopen:false,
      // 审核状态字典
      auditStatusOptions: [],
      // 生产类型(0普通订单，1新增订单，2MRP拉取)字典
      prodTypeOptions: [],
      // 单据状态(0正常，1挂起，2关闭)字典
      docStatusOptions: [],
      // 关闭状态(0自动关闭,1手工关闭)字典
      closeStatusOptions: [],
      // 工单类型(0正常，1超产，2返工)字典
      orderTypeOptions: [],
      // 执行状态字典
      exeStatusOptions: [],
      // 领料标识字典
      pickingMarkOptions: [],
      // 入库标识字典
      inIdenOptions: [],
      //存放选中值的数组
      multipleTable:[],
      //车间
      workshopOptions:[],
      // 班组字典
      teamOptions: [],
      // 班次字典
      frequencyOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      },
      // 表单参数
      form: {},
      form1: {},
      form2: {},
      form3: {},
      form4: {},
      editform:{},
      // 表单校验
      rules: {
        changeReason:[{required: true, message: '请输入申请内容', trigger: 'blur'}],     
        needQuantity: [
          { required: true, message: "计划生产数量不能为空", trigger: "change" },
          {validator:checkminzero,  required: true, message: "不能小于0", trigger: "change" },        
        ],
        startDate: [
          {  required: true, message: "计划生开工日期不能为空", trigger: "change" },
          { validator: checkdate , required: true, message: "计划生完工日期不能比计划开工日期早", trigger: "change" },
        ],
        endDate:[
          { required: true, message: "计划生完工日期不能为空", trigger: "change" },
          { validator: checkdate ,required: true, message: "计划生完工日期不能比计划开工日期早", trigger: "change" },
        ],
        workshop:[
          { required: true, message: "车间不能为空", trigger: "change" },
        ],
         prodLine:[
          { required: true, message: "产线不能为空", trigger: "change" },
        ],
         productCode: [
          { required: true, message: "产品编码不能为空", trigger: "change" },
        ],

         orderType: [
          { required: true, message: "工单不能为空", trigger: "change" },
        ],
        excessRate:[
             {validator:checkminzero,  required: true, message: "不能小于0", trigger: "change" },
        ],
        uplimit:[
             {validator:checkminzero,  required: true, message: "不能小于0", trigger: "change" },
        ],
        poorRate:[
          {validator:checkminzero,  required: true, message: "不能小于0", trigger: "change" },
        ],
        lowlimit:[
             {validator:checkminzero,  required: true, message: "不能小于0", trigger: "change" },
        ]
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("prodplan_workorder_audit_status").then(response => {
      this.auditStatusOptions = response.data;
    });
    this.getDicts("prodplan_workorder_prod_type").then(response => {
      this.prodTypeOptions = response.data;
    });
    this.getDicts("prodplan_workorder_doc_status").then(response => {
      this.docStatusOptions = response.data;
    });
    this.getDicts("prodplan_workorder_close_status").then(response => {
      this.closeStatusOptions = response.data;
    });
    this.getDicts("prodplan_workorder_order_type").then(response => {
      this.orderTypeOptions = response.data;
    });
    this.getDicts("prodplan_workorder_exe_status").then(response => {
      this.exeStatusOptions = response.data;
    });
    this.getDicts("prodplan_workorder_picking_mark").then(response => {
      this.pickingMarkOptions = response.data;
    });
    this.getDicts("prodplan_workorder_in_iden").then(response => {
      this.inIdenOptions = response.data;
    });
 
    this.getDicts("team").then(response => {
      this.teamOptions = response.data;
    });
    this.getDicts("frequency").then(response => {
      this.frequencyOptions = response.data;
    });
  },
  methods: {
    //工单号点击时
    handle(row,column,event,cell) {
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.workshopOptions=response.workshops
        this.editform = response.data;
        this.editopen = true;
        this.title = "修改工单管理";
      });
    },
    
    //远程搜索产品
    loadgoods(query){
      if(query!==''){
       this.loading=true;
      setTimeout(() => {
     getlistprodbycond(query).then(response => {
        this.productOptions = response.rows;
      });
      this.loading=false;
      }, 200);
      }else{
      this.productOptions=[];  
      }
    },
    /** 查询工单管理列表 */
    getList() {
      this.loading = true;
      listPworkorder(this.queryParams).then(response => {
        this.pworkorderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //查询车间名
    getlistWorkShop(){
       listWorkShop().then(response => {
      this.workshopOptions = response.rows;
    });
    },

    // 审核状态字典翻译
    auditStatusFormat(row, column) {
      return this.selectDictLabel(this.auditStatusOptions, row.auditStatus);
    },
    // 生产类型(0普通订单，1新增订单，2MRP拉取)字典翻译
    prodTypeFormat(row, column) {
      return this.selectDictLabel(this.prodTypeOptions, row.prodType);
    },
    // 单据状态(0正常，1挂起，2关闭)字典翻译
    docStatusFormat(row, column) {
      return this.selectDictLabel(this.docStatusOptions, row.docStatus);
    },
    // 关闭状态(0自动关闭,1手工关闭)字典翻译
    closeStatusFormat(row, column) {
      return this.selectDictLabel(this.closeStatusOptions, row.closeStatus);
    },
    // 工单类型(0正常，1超产，2返工)字典翻译
    orderTypeFormat(row, column) {
      return this.selectDictLabel(this.orderTypeOptions, row.orderType);
    },
    // 执行状态字典翻译
    exeStatusFormat(row, column) {
      return this.selectDictLabel(this.exeStatusOptions, row.exeStatus);
    },
    // 领料标识字典翻译
    pickingMarkFormat(row, column) {
      return this.selectDictLabel(this.pickingMarkOptions, row.pickingMark);
    },
    // 入库标识字典翻译
    inIdenFormat(row, column) {
      return this.selectDictLabel(this.inIdenOptions, row.inIden);
    },
    // 班组字典翻译
    teamFormat(row, column) {
      return this.selectDictLabel(this.teamOptions, row.team);
    },
    // 班次字典翻译
    frequencyFormat(row, column) {
      return this.selectDictLabel(this.frequencyOptions, row.frequency);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.open1 = false;
      this.open2 = false;
      this.open3 = false;
      this.open4 = false;
      this.editopen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("form");
      this.editform = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("editform");
      this.form1 = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("form1");
      this.form2 = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("form2");
      this.form3 = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("form3");
      this.form4 = {
        workorderId: undefined,
        orderNum: undefined,
        productId: undefined,
        bomVersion: undefined,
        productCode: undefined,
        productName: undefined,
        specModel: undefined,
        unit: undefined,
        quantity: undefined,
        needQuantity: undefined,
        planningDate: undefined,
        startDate: undefined,
        endDate: undefined,
        auditStatus: undefined,
        prodType: undefined,
        docStatus: undefined,
        closeStatus: undefined,
        orderType: undefined,
        exeStatus: undefined,
        exeLasttime: undefined,
        pickingMark: undefined,
        inIden: undefined,
        workshop: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        isDel: undefined,
        remark: undefined,
        batchNum: undefined,
        bomCode: undefined,
        costObject: undefined,
        docSource: undefined,
        planorderNum: undefined,
        salesorderNum: undefined,
        processCompany: undefined,
        commonUnit: undefined,
        processRoute: undefined,
        goodsCode: undefined,
        basicUnit: undefined,
        basicunitNum: undefined,
        commonunitNum: undefined,
        implQuantity: undefined,
        qualifyinNum: undefined,
        qualifyNum: undefined,
        workdueNum: undefined,
        goodsdueNum: undefined,
        lostNum: undefined,
        workHours: undefined,
        preparationHours: undefined,
        maworkHours: undefined,
        issuanceDate: undefined,
        realstartDate: undefined,
        realendDate: undefined,
        issueman: undefined,
        closeman: undefined,
        closeDate: undefined,
        taskorderNum: undefined,
        forecastNum: undefined,
        singlelineNum: undefined,
        auditMark: undefined,
        strictMark: undefined,
        replenishMark: undefined,
        excessRate: undefined,
        uplimit: undefined,
        basicUplimit: undefined,
        commentUplimit: undefined,
        poorRate: undefined,
        lowlimit: undefined,
        basicLowlimit: undefined,
        commentLowlimit: undefined,
        changeNum: undefined,
        planModel: undefined,
        printNum: undefined,
        trackeNum: undefined,
        prepareHours: undefined,
        associationClose: undefined,
        financialMark: undefined,
        financialMan: undefined,
        financialDate: undefined,
        voucherFont: undefined,
        bomClass: undefined,
        pcassociateNum: undefined,
        basicassociateNum: undefined,
        repairnum: undefined,
        basicRepairnum: undefined,
        scrapmenuNum: undefined,
        reportmenuNum: undefined,
        scrapNum: undefined,
        basicscrapNum: undefined,
        damageNum: undefined,
        basicdamageNum: undefined,
        secondaryName: undefined,
        prodResponsible: undefined,
        jobIntroduce: undefined,
        sendWorkshop: undefined,
        goodsinNum: undefined,
        customerName: undefined,
        sourceNum: undefined,
        makeTime: undefined,
        planDate: undefined,
        customergoodsCode: undefined,
        subordinateFlag: undefined,
        upgoodsNum: undefined,
        totalreportNum: undefined,
        alreadyreportNum: undefined,
        totalstoresNum: undefined,
        goodNum: undefined,
        badNum: undefined,
        source: undefined,
        changeReason: undefined,
        prodLine: undefined,
        team: undefined,
        frequency: undefined
      };
      this.resetForm("form4");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.workorderId)
      this.single = selection.length!==1
      this.multiple = !selection.length
      this.multipleTable = selection;
    },
    /** 新增按钮操作 */
    handleAdd() {      
      this.reset();
      this.getlistWorkShop();      
      this.open = true;
      this.title = "添加工单管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();

      listWorkShop().then(response => {
        this.workshopOptions = response.workshops;
      })
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.workshopOptions=response.workshops
        this.editform = response.data;
              this.getlistWorkShop();      

        this.editopen = true;
        this.title = "修改工单管理";
      });
    },
    /** 挂起按钮操作 */
    handleHangUp(row) {
      this.reset();
      var docStatus = this.multipleTable.map(item => item.docStatus)[0];
      if (docStatus != 0) {
          this.msgSuccess("正常状态可以挂起");
          return;
        }
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.form1 = response.data;
        this.open1 = true;
        this.title = "挂起申请";
      });
    },
    /** 反挂起按钮操作 */
    handleHangDown(row) {
      this.reset();
      var docStatus = this.multipleTable.map(item => item.docStatus)[0];
      if (docStatus != 1) {
          this.msgSuccess("挂起状态可以反挂起");
          return;
        }
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.form2 = response.data;
        this.open2 = true;
        this.title = "反挂起申请";
      });
    },
    /** 结案按钮操作 */
    handleClosed(row) {
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var goodnum = this.multipleTable.map(item => item.goodNum)[0];
      var quantity = this.multipleTable.map(item => item.quantity)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能结案");
          return;
        }
        // if (goodnum < quantity) {
        //   this.msgSuccess("需求数量未达到不能结案");
        //   return;
        // }
        if (exeStatus == 3) {
          this.msgSuccess("已结案，请勿重复结案");
          return;
        }
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.form3 = response.data;
        this.open3 = true;
        this.title = "结案申请";
      });
    },
    /** 反结案按钮操作 */
    handleUnClosed(row) {
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能反结案");
          return;
        }
        if (exeStatus == 0) {
          this.msgSuccess("当前状态为计划，不可点击反结案按钮");
          return;
        }
                if (exeStatus ==1) {
          this.msgSuccess("当前状态为下达，不可点击反结案按钮");
          return;
        }
                if (exeStatus ==2) {
          this.msgSuccess("当前状态为开工，不可点击反结案按钮");
          return;
        }
                if (exeStatus ==4) {
          this.msgSuccess("当前状态为完工，不可点击反结案按钮");
          return;
        }
                if (exeStatus ==5) {
          this.msgSuccess("当前状态为计划确认，不可点击反结案按钮");
          return;
        }
      const workorderId = row.workorderId || this.ids
      getPworkorder(workorderId).then(response => {
        this.form4 = response.data;
        this.open4 = true;
        this.title = "反结案申请";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
        //  ${dict.productId}|${dict.bomVersion}|${dict.productNumber}|${dict.productName}|${dict.specModel}|${dict.productUnit}
        if(this.form.productCode!=null){
           //处理产品编码
          // let tmp = this.form.productCode.split("|");   
          // this.form.productId = parseInt(tmp[0]);
          // this.form.bomVersion = tmp[1];
          // this.form.productCode = tmp[2];
          // this.form.productName = tmp[3];
          // this.form.specModel = tmp[4];
          // this.form.unit = tmp[5];   
        }        
           var codeNum;
          //获取自动编号
          getOrderNum().then(response =>{
            if(response.rows.length<=0){
             this.form.orderNum='WORK00000001';
                      addPworkorder(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
             }
            if(response.rows.length>0){
              codeNum=response.rows[response.rows.length-1].orderNum;
              if(codeNum==null || codeNum==undefined || codeNum==''){
                codeNum='WORK00000001';
              }
               else{
              var prefix=codeNum.replace(/[^a-z]+/ig,"");
              var num=codeNum.replace(/[^0-9]/ig,"");
               ++num;  
                var len = num.toString().length;
                while(len < 8) {
                    num = "0" + num;
                    len++;
                }
            codeNum=prefix+num;
           }
            this.form.orderNum=codeNum;
            addPworkorder(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
            }
          });
        }  
      });   
    },

     //选择车间，加载产线
    getline(value) {
       if(value!=''){  
      this.form.prodLine=''; 
      this.editform.prodLine=''; 
      }
       listLine(value).then((response) => {
         this.LineOptions = response.rows;
       });
    },

    //选择产品编码同步其他产品信息
setallgoods(){
          let tmp = this.form.productCode.split("|");
          console.log(tmp)       
          this.form.productId = parseInt(tmp[0]);       
          this.form.productCode = tmp[1];
          this.form.productName = tmp[2];
          this.form.specModel = tmp[3];
          this.form.unit = tmp[4];
        
},

setallgoodss(){
    let tmp2 = this.editform.productCode.split("|");
          console.log(tmp2+"-----------")       
           this.editform.productId = '';       
          this.editform.productCode = '';
          this.editform.productName = '';
          this.editform.specModel = '';
          this.editform.unit = '';

          this.editform.productId = parseInt(tmp2[0]);       
          this.editform.productCode = tmp2[1];
          this.editform.productName = tmp2[2];
          this.editform.specModel = tmp2[3];
          this.editform.unit = tmp2[4];
},

    editsubmitForm() {
      this.$refs["editform"].validate(valid => {
        if (valid) {
          if (this.editform.workorderId != null) {
            updatePworkorder(this.editform).then(response => {
              this.msgSuccess("修改成功");
              this.editopen = false;
              this.getList();
            });
          } 
        }
      });
    },
    /** 挂起提交按钮 */
    submitForm1() {
      this.$refs["form1"].validate(valid => {
        if (valid) {
          if (this.form1.workorderId != null) {    
             hangup(this.form1).then(response => {
               this.msgSuccess("提交成功");
             });
              this.open1 = false;
              this.getList();
            };      
          } 
      });
    },
     /** 反挂起提交按钮 */
    submitForm2() {
      this.$refs["form2"].validate(valid => {
        if (valid) {
          if (this.form2.workorderId != null) {    
             hangdown(this.form2).then(response => {
               this.msgSuccess("提交成功");
             });
              this.open2 = false;
              this.getList();
            };
          } 
      });
    },
     /** 结案提交按钮 */
    submitForm3() {
      this.$refs["form3"].validate(valid => {
        if (valid) {
          if (this.form3.workorderId != null) {    
             closed(this.form3).then(response => {
               this.msgSuccess("提交成功");
             });
              this.open3 = false;
              this.getList();
            };
          } 
      });
    },
     /** 反挂起提交按钮 */
    submitForm4() {
      this.$refs["form4"].validate(valid => {
        if (valid) {
          if (this.form4.workorderId != null) {    
             unclosed(this.form4).then(response => {
               this.msgSuccess("提交成功");
             });
              this.open4 = false;
              this.getList();
            };
          } 
      });
    },
   /** 删除按钮操作 */
    handleDelete() {

   //获取选中数据
      var data =this.$refs.tableDatas.selection;
                  //删除对应投料记录   删除工单记录
                  this.$confirm('是否确认删除工单管理的数据项?', "警告", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning"
                }).then(function() {
                  return delPworkorder(data);
                }).then(response =>  {
                  this.getList();
                  this.msgSuccess(response.msg);
                })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有工单管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportPworkorder(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
    //计划确认
    handleConfirm(){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
      var data =this.$refs.tableDatas.selection;
      console.log(isLock);
        // var tempArray=new Array();
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能计划确认");
          return;
        }
        if (exeStatus ==1) {
          this.msgSuccess("当前状态为下达，不可点击计划确认按钮");
          
          return;
        }
                if (exeStatus == 2) {
          this.msgSuccess("当前状态为开工，不可点击计划确认按钮");
          return;
        }
                if (exeStatus == 3) {
          this.msgSuccess("当前状态为结案，不可点击计划确认按钮");
          return;
        }
                if (exeStatus == 4) {
          this.msgSuccess("当前状态为完工，不可点击计划确认按钮");
          return;
        }

        if (exeStatus == 5) {
          this.msgSuccess("已确认状态不能计划确认");
          return;
        }
          confirm(data).then(response => {
            this.msgSuccess("计划确认成功");
            this.reset();
            this.getList();
          });
    },
    //反计划确认
    handleUnConfirm(){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
      var data =this.$refs.tableDatas.selection;
        // var tempArray=new Array();
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能反计划确认");
          return;
        }
        if (exeStatus ==0) {
          this.msgSuccess("当前状态为计划，不可点击反计划确认按钮");      
          return;
        }
                if (exeStatus == 1) {
          this.msgSuccess("当前状态为下达，不可点击反计划确认按钮");
          return;
        }
                if (exeStatus == 2) {
          this.msgSuccess("当前状态为开工，不可点击反计划确认按钮");
          return;
        }
                if (exeStatus == 3) {
          this.msgSuccess("当前状态为结案，不可点击反计划确认按钮");
          return;
        }
                if (exeStatus == 4) {
          this.msgSuccess("当前状态为完工，不可点击反计划确认按钮");
          return;
        }
          unConfirm(data).then(response => {
            this.msgSuccess("反计划确认成功");
            this.reset();
            this.getList();
          });
    },
    //下达
    handleIssue(){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
      var data =this.$refs.tableDatas.selection;
        // var tempArray=new Array();
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能下达");
          return;
        }
        if (exeStatus == 0) {
          this.msgSuccess("当前状态为计划，不可点击下达按钮");
          return;
        }
                if (exeStatus == 1) {
          this.msgSuccess("已下达，请勿重复下达");
          return;
        }
                if (exeStatus == 2) {
          this.msgSuccess("当前状态为开工，不可点击下达按钮");
          return;
        }
                if (exeStatus == 3) {
          this.msgSuccess("当前状态为结案，不可点击下达按钮");
          return;
        }
                if (exeStatus == 4) {
          this.msgSuccess("当前状态为完工，不可点击下达按钮");
          return;
        }
          issue(data).then(response => {
            this.msgSuccess("下达成功");
            this.reset();
            this.getList();
          });
    },
    //反下达
    handleUnIssue(row){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
      var upgoodsnum=this.multipleTable.map(item => item.upgoodsNum)[0];
      var data =this.$refs.tableDatas.selection;
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能反下达");
          return;
        }
        if (exeStatus == 0) {
          this.msgSuccess("当前状态为计划，不可点击反下达按钮");
          return;
        }
                if (exeStatus == 2) {
          this.msgSuccess("当前状态为开工，不可点击反下达按钮");
          return;
        }
                if (exeStatus ==3) {
          this.msgSuccess("当前状态为结案，不可点击反下达按钮");
          return;
        }
                if (exeStatus ==4) {
          this.msgSuccess("当前状态为完工，不可点击反下达按钮");
          return;
        }
                if (exeStatus ==5) {
          this.msgSuccess("当前状态为计划确认，不可点击反下达按钮");
          return;
        }
        if (upgoodsnum > 0) {
          this.msgSuccess("已上料不能反下达");
          return;
        }
          unIssue(data).then(response => {
            this.msgSuccess("反下达成功");
            this.reset();
            this.getList();
          });
    },
    //开工
    handleStartUp(row){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
       const workorderIds = row.workorderIds || this.ids;
     
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能开工");
          return;
        }
        if (exeStatus == 0) {
          this.msgSuccess("当前状态为计划，不可点击开工按钮");
          return;
        }   
                if (exeStatus == 2) {
          this.msgSuccess("已开工，请勿重复开工");
          return;
        }  
                if (exeStatus == 3) {
          this.msgSuccess("当前状态为结案，不可点击开工按钮");
          return;
        }  
                if (exeStatus ==4) {
          this.msgSuccess("当前状态为完工，不可点击开工按钮");
          return;
        }  
                if (exeStatus ==5) {
          this.msgSuccess("当前状态为计划确认，不可点击开工按钮");
          return;
        }  
      startup(workorderIds).then(response => {
        this.msgSuccess("开工成功");
        this.getList();
        });     
      
    },

    //级联计算数量与入库上下线计算
    verifynum(flag){
      switch  (flag){
    //新增



    case  "cs":
      //根据计划生产数量和完工入库超收比例计算出完工入库上限
          //this.form.uplimit=(this.form.needQuantity*(1+(this.form.excessRate)/100)).toFixed(4);
          this.form.uplimit= accMul(this.form.needQuantity,accAdd(1,(accDiv(this.form.excessRate,100))));
         
          
        break;
    case  "sx":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
          // this.form.excessRate=(((this.form.uplimit/this.form.needQuantity)-1)*100).toFixed(4)   ;
          
          this.form.excessRate=accMul(accSubtr((accDiv(this.form.uplimit,this.form.needQuantity)),1),100);

        break;
    case  "sl":
      //根据计划生产数量和完工入库超收比例计算出完工入库上限
         // this.form.uplimit=(this.form.needQuantity*(1+(this.form.excessRate)/100)).toFixed(4);
            this.form.uplimit=accMul(accAdd(accDiv(this.form.excessRate,100),1),this.form.needQuantity);   

            
           //根据计划生产数量和完工入库超收比例计算出完工入库上限
         // this.form.lowlimit=(this.form.needQuantity*(1-(this.form.poorRate)/100)).toFixed(4);        
         // this.form.lowlimit=accMul(this.form.needQuantity,(accSubtr(1,accDiv(this.form.poorRate,100))));
        break;
   case  "xx":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
           //this.form.poorRate=(((this.form.lowlimit/this.form.needQuantity)+1)*100).toFixed(4)   ;
           
           this.form.poorRate= accMul(accAdd(accDiv(this.form.lowlimit,this.form.needQuantity),1),100);

        break;
  case  "qs":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
           //this.form.poorRate=(((this.form.lowlimit/this.form.needQuantity)+1)*100).toFixed(4)   ;
          this.form.lowlimit=accMul(this.form.needQuantity,(accSubtr(1,accDiv(this.form.poorRate,100))));
        break;


//修改

 case  "xgcs":
      //根据计划生产数量和完工入库超收比例计算出完工入库上限
          //this.form.uplimit=(this.form.needQuantity*(1+(this.form.excessRate)/100)).toFixed(4);
        
           this.editform.uplimit= accMul(this.editform.needQuantity,accAdd(1,(accDiv(this.editform.excessRate,100))));
          
        break;
    case  "xgsx":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
          // this.form.excessRate=(((this.form.uplimit/this.form.needQuantity)-1)*100).toFixed(4)   ;
          
         
          this.editform.excessRate=accMul(accSubtr((accDiv(this.editform.uplimit,this.editform.needQuantity)),1),100);

        break;
    case  "xgsl":
      //根据计划生产数量和完工入库超收比例计算出完工入库上限
         // this.form.uplimit=(this.form.needQuantity*(1+(this.form.excessRate)/100)).toFixed(4);
           
            this.editform.uplimit=accMul(accAdd(accDiv(this.editform.excessRate,100),1),this.editform.needQuantity);   

            
           //根据计划生产数量和完工入库超收比例计算出完工入库上限
         // this.form.lowlimit=(this.form.needQuantity*(1-(this.form.poorRate)/100)).toFixed(4);        
         // this.form.lowlimit=accMul(this.form.needQuantity,(accSubtr(1,accDiv(this.form.poorRate,100))));
        break;
   case  "xgxx":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
           //this.form.poorRate=(((this.form.lowlimit/this.form.needQuantity)+1)*100).toFixed(4)   ;
           
        
           this.editform.poorRate= accMul(accAdd(accDiv(this.editform.lowlimit,this.editform.needQuantity),1),100);

        break;
  case  "xgqs":
          //根据计划生产数量和完工入库上限计算出完工入库超收比例
           //this.form.poorRate=(((this.form.lowlimit/this.form.needQuantity)+1)*100).toFixed(4)   ;
        
          this.editform.lowlimit=accMul(this.editform.needQuantity,(accSubtr(1,accDiv(this.editform.poorRate,100))));
        break;

     default:
      ;       
}
     
    },
    //反开工
    handleUnStartUp(row){
      this.reset();
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
      var exeStatus = this.multipleTable.map(item => item.exeStatus)[0];
      var data =this.$refs.tableDatas.selection;
      const workorderIds = row.workorderIds || this.ids;
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能反开工");
          return;
        }
        if (exeStatus ==0) {
          this.msgSuccess("当前状态为计划，不可点击反开工按钮");
          return;
        }
                if (exeStatus ==1) {
          this.msgSuccess("当前状态为下达，不可点击反开工按钮");
          return;
        }
                if (exeStatus ==3) {
          this.msgSuccess("当前状态为结案，不可点击反开工按钮");
          return;
        }
                if (exeStatus ==4) {
          this.msgSuccess("当前状态为完工，不可点击反开工按钮");
          return;
        }
                if (exeStatus ==5) {
          this.msgSuccess("当前状态为计划确认，不可点击反开工按钮");
          return;
        }
      unStartup(workorderIds).then(response => {
        this.msgSuccess("反开工成功");
        this.getList();
        });
    },
    //完工
    handleCompletion(row){
      this.reset();
      var goodnum = this.multipleTable.map(item => item.goodNum)[0];
      var quantity = this.multipleTable.map(item => item.quantity)[0];
      var isLock = this.multipleTable.map(item => item.docStatus)[0];
        if (isLock == 1) {
          this.msgSuccess("挂起状态不能完工");
          return;
        }
        if (goodnum < quantity) {
          this.msgSuccess("需求数量未达到不能完工");
          return;
        }
      const workorderIds = row.workorderIds || this.ids;
      completion(workorderIds).then(response => {
        this.msgSuccess("完工成功");
        this.getList();
        });    
    },
  }
};
</script>
